<?php 

@header('Content-Type: text/html; charset=UTF-8');

 $errorMsgs = [
            'out_trade_no' => '订单号(out_trade_no)不能为空',
            'notify_url' => '通知地址(notify_url)不能为空',
            'return_url' => '回调地址(return_url)不能为空',
            'name' => '商品名称(name)不能为空',
            'money' => '金额(money)不能为空',
            'max_money' => '最大支付金额是' . $conf['pay_maxmoney'] . '元',
            'min_money' => '最小支付金额是' . $conf['pay_minmoney'] . '元',
            'invalid_money' => '金额不合法',
            'invalid_out_trade_no' => '订单号(out_trade_no)格式不正确',
            'insufficient_balance' => '当前商户额度不足[' . $postdata['money'] . ']，所以无法生成此订单,请商户们自行进行充值',
            'member_not_found' => '当前商户未开通此通道会员，所以无法生成此订单,请商户们自行进商户中心开通',
        ];
    
    // 检查必要参数
    // var_dump($queryArr);exit;
    foreach (['out_trade_no', 'notify_url', 'return_url', 'name', 'money'] as $field) {
        if (empty($queryArr[$field]))  sysmsg($errorMsgs[$field]);
    }
    $trade_no = $queryArr['out_trade_no'];
    $paytype = ['wxpay','qqpay','alipay','usdtpay'];
?>
<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=0" name="viewport">
<title>收银台 | <?php echo $sitename?$sitename:$conf['sitename']?> </title>
<link href="/Core/assets/css/reset.css" rel="stylesheet" type="text/css">
<link href="/Core/assets/css/main12.css?v=2" rel="stylesheet" type="text/css">
</head>
<body style="background-color:#f9f9f9">
<!--导航-->
<div class="w100 navBD12">
    <div class="w1080 nav12">
        <div class="nav12-left">
            <img src="/Core/assets/img/logo.png">
        </div>
		<div class="nav12-right">
            收银台
        </div>

    </div>
</div>
<input type="hidden" name="trade_no" value="<?php echo $trade_no?>"/>
<div class="w1080 order-amount12">
    <ul class="order-amount12-left">
        <li>
            <span>商品名称：</span>
            <span><?php echo $queryArr['name']?></span>
        </li>
        <li>
            <span>订单号：</span>
            <span><?php echo $trade_no?></span>
        </li>
    </ul>
    <div class="order-amount12-right">
        <span>订单金额：</span>
        <strong><?php echo $queryArr['money']?></strong>
        <span>元</span>
    </div>  
</div>
<div class="w1080 PayMethod12">
    <div class="row">
        <h2>支付方式</h2>
        <ul class="types">
		<?php foreach($paytype as $type){?>
          <li class="pay_li" value="<?php echo $type?>">
             <img src="/Core/assets/icon/<?php echo $type?>.ico">
                    <span><?php echo pay_type($type)?></span>
          </li>
		<?php }?>
        </ul>
    </div>
</div>
<div class="w1080 immediate-pay12">
  <div class="immediate-pay12-right">
      <span>需支付：<strong><?php echo $queryArr['money'];?>元</span>
        <a class="immediate_pay">立即支付</a>
    </div>
</div>
<script src="<?=JQueryJS?>"></script>
<script src="<?=LayerJS?>"></script>
<script src="<?=CommonJs?>"></script>
<script>
$(document).ready(function() {
    $('.pay_li').click(function() {
        $('.pay_li').removeClass('active');
        $(this).addClass('active');
    });

    $('.immediate_pay').click(function() {
        var selectedType = $('.pay_li.active').attr('value');
        if (!selectedType) {
            falsemsg(layer,"请选择支付方式");
            return;
        }

        var baseUrl = '/submit1.php'; 
        var currentQuery = '<?php echo http_build_query($queryArr); ?>';
        var newUrl = baseUrl + '?' + currentQuery + '&type=' + selectedType;

        window.location.href = newUrl;
    });
});
</script>
</body>
</html>